// Copyright 2011 George Cook
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#import "InjectivePropertyDescription.h"


@implementation InjectivePropertyDescription
@synthesize propertyName, sourcePropertyName;
@synthesize value;
@synthesize type;
@synthesize idRef;

#pragma mark -
#pragma mark Static methods
+ (id) propertyDescriptionWithPropertyName : (NSString *) propertyName andValue : (InjectivePropertyValueDescription *) value
{
	return [[[InjectivePropertyDescription alloc] initWithPropertyName:propertyName andValue: value] autorelease];
}

+ (id) propertyDescriptionWithPropertyName:(NSString *) propertyName andRef:(id) ref andSourcePropertyName:(NSString *) sourcePropertyName
{
	InjectivePropertyDescription *propertyDescription = [self propertyDescriptionWithPropertyName:propertyName andRef:ref];
	propertyDescription.sourcePropertyName = sourcePropertyName;
	return propertyDescription;
}

+ (id) propertyDescriptionWithPropertyName:(NSString *) propertyName andType:(id) type andSourcePropertyName:(NSString *) sourcePropertyName
{
	InjectivePropertyDescription *propertyDescription = [self propertyDescriptionWithPropertyName:propertyName andType:type];
	propertyDescription.sourcePropertyName = sourcePropertyName;
	return propertyDescription;
}


+ (id) propertyDescriptionWithPropertyName:(NSString *) propertyName andRef:(id) ref
{
	return [[[InjectivePropertyDescription alloc] initWithPropertyName:propertyName andRef: ref] autorelease];
}

+ (id) propertyDescriptionWithPropertyName:(NSString *) propertyName
{
	InjectivePropertyDescription *propertyDescription = [[[InjectivePropertyDescription alloc] init ] autorelease];
	propertyDescription.propertyName = propertyName;
	return propertyDescription;
}

+ (id) propertyDescriptionWithPropertyName:(NSString *) propertyName andType:(id) type
{
	return [[[InjectivePropertyDescription alloc] initWithPropertyName:propertyName andType: type] autorelease];
}

#pragma mark -
#pragma mark init and dealloc

- (void)dealloc
{
	[propertyName release], propertyName = nil;
	[value release], value = nil;
	[type release], type = nil;
	[idRef release], idRef = nil;
	[super dealloc];
}

- (id)initWithPropertyName:(NSString *) aPropertyName andValue:(InjectivePropertyValueDescription *) aValue
{
	if (self = [super init]) {
		propertyName = [aPropertyName retain];
		value = [aValue retain];
	}
	return self;
}

- (id)initWithPropertyName:(NSString *) aPropertyName andRef:(id) aRef
{
	if (self = [super init]) {
		propertyName = [aPropertyName retain];
		idRef = [aRef retain];
	}
	return self;
}

- (id)initWithPropertyName:(NSString *) aPropertyName andType:(id) aType
{
	if (self = [super init]) {
		type = [aType retain];
		propertyName = [aPropertyName retain];
	}
	return self;
}

#pragma mark description
- (NSString *)description
{
	return [[super description] stringByAppendingFormat:@"propertyName %@ IDRef: %@ value: %@ type %@",
			self.propertyName, self.idRef, self.value, self.type];
}

@end